#ifndef LOGGERACTIVATORFILTER_H_JM_20130121
#define LOGGERACTIVATORFILTER_H_JM_20130121


#include <string>
#include <cassert>

namespace jmlib {
	class LoggerActivatorFilter {
	public:
		enum FiltrationMethod { EXACT_MATCH, PREFIX_MATCH };
		LoggerActivatorFilter(const std::string& filter, FiltrationMethod method, 
			const std::string& appenderName) 
			: filter_(filter),
			filtrationMethod_(method),
			appenderName_(appenderName) { };

		bool isLoggerAccepted(const std::string& logger) const {
			// Pokial je filter prazdny -> je akceptovane vsetko. (spoliehaju sa 
			// na to vyssie vrstvy)
			if (filter_.empty()) return true;
			switch (filtrationMethod_) {
			case EXACT_MATCH: return logger == filter_;
			case PREFIX_MATCH: return logger.find(filter_) == 0;
			default:
				assert(false);
			}
			return false;
		}

		const std::string& getAppenderName() const { return appenderName_; }
		bool areAcceptedAllAppenders() const { return appenderName_.empty(); }
	private:
		std::string filter_;
		FiltrationMethod filtrationMethod_;
		std::string appenderName_;
	};	
} // namespace jmlib	


#endif
